﻿using System.Collections.Generic;
using System.Linq;

using Insesoft.Entities;
using NHibernate;
using NHibernate.Linq;

namespace InseSoft.UIControllers
{
    public class OrdenController : Controller
    {
        #region Constructors

        public OrdenController(){ }

        public OrdenController(ISession session) : base(session) { }

        #endregion

        #region Methods: Public

        public IList<Orden> GetByStatus(bool inProgress)
        {
            var query = from o in Session.Query<Orden>()
                        where (o.Empresa == ApplicationSession.Instance.Empresa)
                        select o;
            if (inProgress)
                query = query.Where(o => o.FecFinal == null || o.FecFinal > CurrentDateProvider());

            return query.ToList();
        }

        #endregion
    }
}
